#include <graphics/Billboard.h>

namespace ne
{
    Billboard::Billboard()
        : position(Vector3::ZERO),
          width(1.0f), height(1.0f),
          axis(Vector3::UNIT_Y),
          rotation(0.0f),
          color(Color::WHITE)
    {
        resetTexCoord();
    }

    Billboard::Billboard(const Billboard &bb)
        : position(bb.position),
          width(bb.width), height(bb.height),
          axis(bb.axis),
          rotation(bb.rotation),
          color(bb.color)
    {
        texCoords[0] = bb.texCoords[0];
        texCoords[1] = bb.texCoords[1];
    }

    Billboard& Billboard::operator = (const Billboard &bb)
    {
        position = bb.position;
        width = bb.width;
        height = bb.height;
        axis = bb.axis;
        rotation = bb.rotation;
        color = bb.color;
        texCoords[0] = bb.texCoords[0];
        texCoords[1] = bb.texCoords[1];
        return *this;
    }

    void Billboard::setSize(const real w, const real h)
    {
        width = w;
        height = h;
    }

    void Billboard::resetSize()
    {
        width = 1.0f;
        height = 1.0f;
    }

    Vector4 Billboard::getTexCoord() const
    {
        return Vector4(texCoords[0].x, texCoords[0].y,
                       texCoords[1].x, texCoords[1].y);
    }

    void Billboard::setTexCoord(const Vector4 &t01)
    {
        texCoords[0].x = t01.x;
        texCoords[0].y = t01.y;
        texCoords[1].x = t01.z;
        texCoords[1].y = t01.w;
    }

    void Billboard::setTexCoord(const Vector2 &t0, const Vector2 &t1)
    {
        texCoords[0] = t0;
        texCoords[1] = t1;
    }

    void Billboard::setTexCoord(const real u0, const real v0,
                                const real u1, const real v1)
    {
        texCoords[0].x = u0;
        texCoords[0].y = v0;
        texCoords[1].x = u1;
        texCoords[1].y = v1;
    }

    void Billboard::resetTexCoord()
    {
        texCoords[0] = Vector2::ZERO;
        texCoords[1] = Vector2::ONE;
    }

    Billboard::~Billboard()
    {
    }
}
